import xml.etree.ElementTree as ET
from xml.dom import minidom

def pretty_xml(element):
    """将ElementTree元素转换为格式化（美化）的XML字符串，方便调试"""
    rough_string = ET.tostring(element, 'utf-8')
    reparsed = minidom.parseString(rough_string)
    return reparsed.toprettyxml(indent="  ")